package cn.edu.tsinghua.ie.ieFunds.service;

import cn.edu.tsinghua.ie.ieFunds.bean.bussiness.Fund;
import cn.edu.tsinghua.ie.ieFunds.repository.FundRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class FundService {

    @Autowired
    private FundRepository fundRepository;

//    public Fund getFundByUserName(String userName) {
//        return fundRepository.findFundByUsername(userName);
//    }

    public Fund getFundByFundUid(String fundUid) {
        return fundRepository.findFundByUid(fundUid);
    }

    @Transactional
    public void add(Fund fund) {
        fundRepository.save(fund);
    }

    public List<Fund> findFundListByUsername(String username) {
        return fundRepository.findAllByUsername(username);
    }
}
